﻿@{
    ViewBag.Title = "日志列表";
}
@section headerSection{
    <style>
        #exampleToolbar > .form-group {
            float: left;
            margin: 0;
            margin-left: 5px;
        }
    </style>
}
<div class="animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins" style="margin-bottom: 0px;">
        <div class="ibox-content" style="padding: 5px 20px 0px 20px;">
            <div class="row row-lg">
                <div class="col-sm-12 col-sm-leftRight">
                    <!-- Example Toolbar -->
                    <div class="example">
                        <div class="btn-group hidden-xs" id="exampleToolbar" role="group">
                            <button id="logDetail" type="button" class="btn btn-outline btn-primary">
                                <i class="glyphicon glyphicon-th-large" aria-hidden="true">详细</i>
                            </button>
                            <div class="form-group" style="width:120px;">
                                <input id="user_name" name="user_name" type="text" class="form-control" placeholder="操作用户">
                            </div>
                            <div class="form-group" style="width:120px;">
                                <input id="page_name" name="page_name" type="text" class="form-control" placeholder="页面名称">
                            </div>
                            <div class="form-group" style="margin-top:-2px;width:180px;">
                                <select id="module_code" name="module_code" title="请选择所属模块" class="form-control show-tick selectpicker" placeholder="请选择所属模块"></select>
                            </div>
                            <div class="form-group" style="width:140px;">
                                <input id="in_date" name="in_date" type="text" class="laydate-icon form-control input-sm" placeholder="开始时间" title="开始时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" />
                            </div>
                            <div class="form-group" style="width:140px;">
                                <input id="end_date" name="end_date" type="text" class="laydate-icon form-control input-sm" placeholder="截止时间" title="截止时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" />
                            </div>
                            <div class="form-group">
                                <button id="btnSearch" class="btn btn-primary" type="button"><i class="fa fa-search"></i>&nbsp;查询</button>
                            </div>
                        </div>
                        <table id="exampleTableToolbar" data-mobile-responsive="true" data-radio="true"></table>
                    </div>
                    <!-- End Example Toolbar -->
                </div>
            </div>
        </div>
    </div>
    <!-- End Panel Other -->
</div>
<!-- 详细 -->
<div id="logForm" style="width: 430px; overflow: hidden; display: none;">
    <form class="form-horizontal m-t" id="logFormTable" method="post">
        <div class="form-group">
            <label class="col-sm-4 control-label">所属模块：</label>
            <div class="col-sm-7">
                <input id="module_name" name="module_name" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">操作用户：</label>
            <div class="col-sm-7">
                <input id="user_name" name="user_name" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">所属页面：</label>
            <div class="col-sm-7">
                <input id="page_name" name="page_name" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">IP：</label>
            <div class="col-sm-7">
                <input id="ip" name="ip" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">操作按钮：</label>
            <div class="col-sm-7">
                <input id="button_name" name="button_name" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">操作时间：</label>
            <div class="col-sm-7">
                <input id="create_date" name="create_date" type="text" class="form-control input-sm" disabled="disabled" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">操作内容：</label>
            <div class="col-sm-7">
                <textarea class="form-control" id="context" name="context" rows="3" disabled="disabled"></textarea>
            </div>
        </div>
    </form>
</div>
@section footSection{
    <script>
        var options, $table;
        var logManager = {
            initPage: function () {
                logManager.initSelect();
                logManager.initTable();
                logManager.bindEvent();
            },
            //初始化下拉
            initSelect:function() {
                $('#module_code').initModuleSelectpicker();
            },
            //初始化Table
            initTable: function() {
                options = {
                    url: ctx + "/SysLog/GetLogTable",
                    cutHeight: 5,
                    toolbar: "#exampleToolbar",
                    queryParams: function(params) {
                        params = {
                            //页面大小  
                            rows: params.limit,
                            //第几页
                            page: params.offset / params.limit + 1,
                            user_name: $('#user_name').val(),
                            page_name: $('#page_name').val(),
                            module_code: $('#module_code').val(),
                            in_date: $('#in_date').val(),
                            end_date: $('#end_date').val()
                        }
                        return params;
                    },
                    columns: [
                        {
                            radio: true
                        }, {
                            field: '', //第一列序号
                            title: '序号',
                            align: 'center',
                            width: 50,
                            formatter: function(value, row, index) {
                                return index + 1;
                            }
                        }, {
                            field: 'module_name',
                            title: '所属模块',
                            align: 'center'
                        }, {
                            field: 'user_name',
                            title: '操作用户',
                            align: 'center'
                        }, {
                            field: 'page_name',
                            title: '所属页面',
                            align: 'center'
                        }, {
                            field: 'ip',
                            title: 'IP',
                            align: 'center'
                        }, {
                            field: 'context',
                            title: '内容',
                            align: 'center',
                            formatter: function (value, row, index) {
                                if (value && value.toString().length > 15)
                                    return "<span title='" + value + "'>" + value.substring(0, 15) + "...</span>";
                                else
                                    return "";
                            }
                        }, {
                            field: 'button_name',
                            title: '按钮',
                            align: 'center'
                        }, {
                            field: 'create_date',
                            title: '操作日期',
                            align: 'center'
                        }]
                }
                $table = tableHelper.initTable("exampleTableToolbar", options);
            },
            //绑定事件
            bindEvent: function() {
                //查询
                $('#btnSearch').click(function () {
                    $table.bootstrapTable('refresh', options);
                });
                //详细
                $('#logDetail').click(function () {
                    var row = $table.bootstrapTable('getSelections');
                    if (row && row.length === 0) {
                        layer.msg("未选中行~", { icon: 5 });
                        return false;
                    }
                    //清空表单
                    $('#logFormTable').resetHideValidForm();
                    layer.open({
                        title: ['操作详细信息', 'font-size:18px;'],
                        type: 1,
                        content: $('#logForm'),
                        scroll: true, //是否显示滚动条、默认不显示
                        btn: ['确定', '取消'],
                        area: ['480px', '98%'],
                        success: function(li, o) {
                            if (row != null) {
                                $('#logFormTable')[0].reset(); //重置表单
                                $('#logFormTable').LoadForm(row[0]); //表单填充数据
                            }
                        }
                    });
                });
            }
        }
        $(function() {
            logManager.initPage();
        });
    </script>

}